#pragma once
#include "BondDealMatrixData.h"
#include <widgets/STips.h>
#include <QStylePainter>
#include <QTimer>
#include <QWidget>
#include <vector>

class BondDealMatrixImpl;
class BondDealMatrixBlockBase : public QWidget
{
	enum eFillMode {
		eModeBlock = 0,
		eModeHorz,
		eModeVert
	};

public:
	BondDealMatrixBlockBase(BondDealMatrixImpl* p);

	void showCell(bool bShow);
	void updateCell(int bondIndex, bool needFlash);

protected:
	virtual void paintEvent(QPaintEvent* event) override;
	virtual void mouseMoveEvent(QMouseEvent* event) override;
	virtual void mouseDoubleClickEvent(QMouseEvent* event) override;
	void updateString();
	void updateTipsString(QString& strTitle);
	void drawBack(QStylePainter& painter);

protected slots:
	void onTimeOut();

protected:
	BondDealMatrixImpl* m_parent = nullptr;
	//data
	int m_bondIndex = -1;
	QString m_strTitle, m_strPrice, m_strDiff;
	double m_gapBP = -1e7;

	//draw
	QFont m_lfTitle, m_lfPrice, m_lfDiff, m_lfOperator;
	bool m_show = false;
	QTimer* m_flashTimer = nullptr;
	int m_flashPos = 0;

	//tips
	QString m_strTips;
	std::vector<qb::QBTipCustomItem> m_vctTipsCustomItem;
};